import { reactive } from "vue";
import { getCustomerSelectList } from "@/api/managementCenter/customerManagement";
import { getAllCompanyApi, getUserByPositionApi } from "@/api/managementCenter/departmentPersonnel";
import { getTreeChannelApi } from "@/api/configCenter/warehouseEntryChannel";
import { TreeSelect } from "ant-design-vue";
const SHOW_CHILD = TreeSelect.SHOW_CHILD;

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "海外仓运单号",
    keyName: "warehouseBillNumList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "客户简称",
    keyName: "customerIdList",
    optionsRequest: getCustomerSelectList,
    optReqParams: { isFilterChild: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "shortName",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "经营单位",
    keyName: "companyIdList",
    optionsRequest: getAllCompanyApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "name",
      value: "id"
    },
    options: []
  }),
  {
    type: "select",
    label: "运单类型",
    keyName: "addressType",
    optConfig: {
      label: "label",
      value: "value"
    },
    options: [
      {
        label: "FBA",
        value: 1
      },
      {
        label: "沃尔玛",
        value: 2
      },
      {
        label: "私人地址",
        value: 3
      }
    ]
  },
  reactive<SuperSearch.SearchItem>({
    type: "cascader",
    label: "渠道",
    keyName: "channelIdList",
    optionsRequest: getTreeChannelApi,
    optReqParams: {},
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "label",
      value: "value",
      children: "children"
    },
    attrs: {
      multiple: true,
      showCheckedStrategy: SHOW_CHILD
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "业务员",
    keyName: "bizIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "4", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "跟单员",
    keyName: "followIdList",
    optionsRequest: getUserByPositionApi,
    optReqParams: { position: "5", status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    attrs: {
      mode: "multiple"
    },
    optConfig: {
      label: "username",
      value: "id"
    },
    options: []
  })
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  "0": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "180"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "120"
    },
    {
      field: "skuCount",
      title: "产品数量",
      minWidth: "120"
    },
    {
      field: "receiveBillAmount",
      title: "应收款",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "120"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "120"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  "1": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "180"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "companyName",
      title: "经营单位",
      minWidth: "120"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "120"
    },
    {
      field: "skuCount",
      title: "产品数量",
      minWidth: "120"
    },
    {
      field: "receiveBillAmount",
      title: "应收款",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "120"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "120"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  "2": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "180"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "120"
    },
    {
      field: "skuCount",
      title: "产品数量",
      minWidth: "120"
    },
    {
      field: "receiveBillAmount",
      title: "应收款",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "120"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "120"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  "3": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "180"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "120"
    },
    {
      field: "skuCount",
      title: "产品数量",
      minWidth: "120"
    },
    {
      field: "receiveBillAmount",
      title: "应收款",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "120"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "120"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ],
  "4": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "warehouseBillNum",
      title: "海外仓运单号",
      minWidth: "180"
    },
    {
      field: "customerName",
      title: "客户简称",
      minWidth: "120"
    },
    {
      field: "addressType",
      title: "运单类型",
      minWidth: "120",
      renderSlot: "addressType"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "120"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "120"
    },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "120"
    },
    {
      field: "squaresNumber",
      title: "方数",
      minWidth: "120"
    },
    {
      field: "skuCount",
      title: "产品数量",
      minWidth: "120"
    },
    {
      field: "receiveBillAmount",
      title: "应收款",
      minWidth: "120"
    },
    {
      field: "bizName",
      title: "业务员",
      minWidth: "120"
    },
    {
      field: "followName",
      title: "跟单员",
      minWidth: "120"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "120"
    },
    {
      field: "innerRemark",
      title: "内部备注",
      minWidth: "120"
    },
    {
      field: "action",
      title: "操作",
      minWidth: "140",
      fixed: "right",
      renderSlot: "action"
    }
  ]
};
